Skip to content

Conversation

JonathanBrouwer
Copy link
Contributor

@JonathanBrouwer JonathanBrouwer commented Jun 29, 2025

Ports link to the new attribute parsing infrastructure for #131229 (comment)

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jun 29, 2025
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jun 30, 2025

☔ The latest upstream changes (presumably #143233) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Jul 15, 2025
@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer JonathanBrouwer force-pushed the link_rework branch 6 times, most recently from 29b3648 to 6b10a20 Compare July 16, 2025 11:47
PrintAttribute
)]
#[derive(HashStable_Generic)]
pub enum NativeLibKind {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type was moved here because it is needed for the link attribute and the original location caused a dependency cycle


#[link(name = "bar", import_name_type = "decorated", kind = "raw-dylib")]
#[link(name = "bar", kind = "raw-dylib")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not testing for the invalid attribute, but instead for the link attribute on an extern type. Because attributes are parsed earlier and this attribute was invalid the error blocked the crash from happening. This is true for quite a few other of the test changes as well

@@ -81,8 +81,7 @@
#[export_stable = 1]
//~^ ERROR malformed
#[link]
//~^ ERROR attribute must be of the form
//~| WARN this was previously accepted by the compiler
//~^ ERROR malformed
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BREAKING CHANGE 1: A #[link] attribute which is not a list #[link(...)] used to be a warning future error, is now an error. This needs a crater run.

@@ -61,7 +61,7 @@
#![doc = "2400"]
#![cold] //~ WARN attribute should be applied to a function
//~^ WARN this was previously accepted
#![link()] //~ WARN attribute should be applied to an `extern` block
#![link(name = "x")] //~ WARN attribute should be applied to an `extern` block
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BREAKING CHANGE 2: A link attribute applied to an invalid target was not checked for syntactic correctness, it now is. The invalid target remains a warning, but the syntactic corectness is now checked

@JonathanBrouwer
Copy link
Contributor Author

@rustbot ready
r? @jdonszelmann

Needs a crater run

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jul 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 16, 2025

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@JonathanBrouwer JonathanBrouwer marked this pull request as ready for review July 16, 2025 12:25
@rustbot
Copy link
Collaborator

rustbot commented Jul 16, 2025

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred in compiler/rustc_attr_data_structures

cc @jdonszelmann

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@jdonszelmann
Copy link
Contributor

@bors try @craterbot queue

bors added a commit that referenced this pull request Jul 16, 2025
Port `#[link]` to the new attribute parsing infrastructure

Ports `link` to the new attribute parsing infrastructure for #131229 (comment)

This rework is not yet finished, it is blocked on the `cfg` attribute being finished, since `link` takes a `cfg` attribute as argument

`@rustbot` blocked
@bors
Copy link
Collaborator

bors commented Jul 16, 2025

⌛ Trying commit 6b10a20 with merge 4797991...

@bors
Copy link
Collaborator

bors commented Jul 16, 2025

☀️ Try build successful - checks-actions
Build commit: 4797991 (4797991aa2efb6d658150f10425b3f3b5d10eceb)

@jdonszelmann
Copy link
Contributor

@craterbot queue

@craterbot
Copy link
Collaborator

🚨 Error: failed to parse the command

🆘 If you have any trouble with Crater please ask in t-infra on Zulip
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@Zalathar
Copy link
Contributor

Failed in rollup, in a Windows-specific test: #145865 (comment)

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 26, 2025
@jdonszelmann
Copy link
Contributor

:/

@ChrisDenton
Copy link
Member

Would it be possible to change the test to a check-pass and set the target instead of only running on x86 windows host?

@JonathanBrouwer
Copy link
Contributor Author

Hmmm that seems reasonable for at least this specific test. There's actually a bunch of windows only tests for link, I'll see how many I can convert

@ChrisDenton
Copy link
Member

I quickly tried this. Here's what I came up with:

//@ add-core-stubs
//@ check-pass
//@ compile-flags: --target i686-pc-windows-msvc
// maybe also test i686-pc-windows-gnu?
#![feature(no_core, rustc_attrs, lang_items)]
#![no_core]
#![crate_type = "lib"]

#[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
//~^ ERROR import name type must be of the form `import_name_type = "string"`
extern "C" {}

Unfortunately no_core is needed because otherwise it complains about not having std available.

@JonathanBrouwer
Copy link
Contributor Author

JonathanBrouwer commented Aug 26, 2025

@ChrisDenton I followed your trick (thanks a lot!) and I think I have all tests working now, but I didn't verify on a windows VM since after an hour of trying to get it working I still can't build the rust project using it, no clue why, getting weird errors and everything is super slow for some reason

@jdonszelmann Could you do a try run of @bors try jobs=i686-msvc-1,i686-msvc-2,aarch64-msvc-1,aarch64-msvc-2

@jdonszelmann
Copy link
Contributor

@bors try jobs=i686-msvc-1,i686-msvc-2,aarch64-msvc-1,aarch64-msvc-2

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 26, 2025
Port `#[link]` to the new attribute parsing infrastructure

try-job: i686-msvc-1
try-job: i686-msvc-2
try-job: aarch64-msvc-1
try-job: aarch64-msvc-2
@rust-bors
Copy link

rust-bors bot commented Aug 26, 2025

☀️ Try build successful (CI)
Build commit: c6a57b6 (c6a57b68f09c4ac5f467f06828ec440b93620413, parent: 5ab69249f36678c0a770a08d3d1b28a8103349ff)

@bors
Copy link
Collaborator

bors commented Aug 27, 2025

☔ The latest upstream changes (presumably #145906) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot
Copy link
Collaborator

rustbot commented Aug 27, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@jdonszelmann
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 28, 2025

📌 Commit 7db1840 has been approved by jdonszelmann

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 28, 2025
bors added a commit that referenced this pull request Aug 28, 2025
Rollup of 9 pull requests

Successful merges:

 - #142727 (wasm: rm static mut)
 - #143193 (Port `#[link]` to the new attribute parsing infrastructure )
 - #144864 (No source fixes)
 - #145913 (Add spin_loop hint for LoongArch)
 - #145926 (compiletest: Remove several remnants of the old libtest-based executor)
 - #145928 (Rename `Location::file_with_nul` to `file_as_c_str`)
 - #145930 (`const`ify (the unstable) `str::as_str`)
 - #145941 (Disable `integer_to_ptr_transmutes` suggestion for unsized types)
 - #145953 (Update `icu_list` to 2.0)

r? `@ghost`
`@rustbot` modify labels: rollup
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Aug 28, 2025
@bors bors merged commit a65ed63 into rust-lang:master Aug 28, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 28, 2025
rust-timer added a commit that referenced this pull request Aug 28, 2025
Rollup merge of #143193 - JonathanBrouwer:link_rework, r=jdonszelmann

Port `#[link]` to the new attribute parsing infrastructure

Ports `link` to the new attribute parsing infrastructure for #131229 (comment)
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Aug 28, 2025
…=jdonszelmann

Improve error messages around invalid literals in attribute arguments

r? `@jdonszelmann`

This previously created two errors, which is a bit ugly and the second one didn't add any value
Blocked on rust-lang#143193
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-run-make Area: port run-make Makefiles to rmake.rs disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team
Projects
None yet
Development

Successfully merging this pull request may close these issues.